package com.itheima.HomeWork.zuoye1;


import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/*请编写main()方法：
          1). 使用反射获取Student的Class对象。
          2). 获取 “公有、全参构造方法”；
          3). 调用 “公有、全参构造方法”传入：“柳岩”,17两个参数。
          4). 反射获取show()方法
          5). 调用show()方法*/
public class ClassDemo {
     public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        /* Class<Student> studentClass = Student.class;
         Student student = studentClass.getConstructor().newInstance();
         Method show = studentClass.getDeclaredMethod("show",String.class);
         Method show1 = studentClass.getDeclaredMethod("show",Integer.class);
         //show.setAccessible(true);
         String invoke = (String) show.invoke(student, "柳岩");
         Integer invoke1 = (Integer) show1.invoke(student,  17);
         System.out.println(invoke);*/
         Class studentClass = Student.class;
         Student student = new Student();
         student.setName("柳岩");
         student.setAge(17);
         Method show = studentClass.getDeclaredMethod("show");
         show.invoke(student);

     }
}
